﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ClientNetwork;
using System.Security.Cryptography;
using System.Data;

namespace CHAPClient
{
    enum HandShakeStage
    {
        Challenge = '1',
        HandShake = '2'
    }

    public static class CHAP
    {
        public static DataTable Login(string username, string pass)
        {
            //  Server will send us the challenge key
            DataTable Challenge = Challenge = Protocol.Command(SaunaProtocol.Login, HandShakeStage.Challenge.ToString() + '@' + username);

            //  Generate our proposed hash key from the challenge key
            string UserKey = Util.Hash(pass + Challenge);

            DataTable result = Protocol.Command(SaunaProtocol.Login, HandShakeStage.HandShake.ToString() + '@' + username + '@' + UserKey);

            return result;
        }
    }
}
